;;; +base.el --- basic configs -*- lexical-binding: t -*-

;;; Commentary:

;;; Code:

;; ;; -------- faster init via centaur.emacs --------
;; ;; Package initialize occurs automatically, before `user-init-file' is
;; ;; loaded, but after `early-init-file'. We handle package
;; ;; initialization, so we must prevent Emacs from doing it early!
;; (add-hook 'before-init-hook
;;           (lambda ()
;;             ))

;; -------- after-init-hook --------
(add-hook 'after-init-hook
          (lambda ()
            ;; scratch buffer mode
            ;; (setq initial-major-mode 'emacs-lisp-mode)
            (setq inhibit-startup-message t)
            (setq initial-scratch-message
                  ";; 道友留步，\n;; Enjoy counting the parentheses!\n\n")
            (setq inhibit-splash-screen t
                  inhibit-startup-screen t
                  inhibit-startup-echo-area-message t)
            ))

;; -------- emacs-startup-hook --------
(add-hook 'emacs-startup-hook
          (lambda ()
            ;; display init time
            (message "Emacs ready in %s with %d garbage collections."
                     (format "%.2f seconds"
                             (float-time
                              (time-subtract after-init-time before-init-time)))
                     gcs-done)
            (setq file-name-handler-alist nil)))

;; -------- window-setup-hook --------
(add-hook 'window-setup-hook
          (lambda ()
            ;; cursor never blink
            (blink-cursor-mode -1)
            ;; highlight current line
            (global-hl-line-mode 1)
            ;; auto reload file
            (global-auto-revert-mode 1)
            ;; undisplay minor-mode on mode-line
            (diminish 'abbrev-mode)
            (diminish 'auto-revert-mode)
            (diminish 'eldoc-mode)
            (diminish 'page-break-lines-mode)
            (diminish 'valign-mode)
            ;; save place in file
            (save-place-mode 1)))

;; -------- disable bell sound --------
(setq ring-bell-function 'ignore)

;; -------- no file.bk~ --------
(setq make-backup-files nil)

;; -------- sentence end and Not with double space --------
(setq sentence-end "\\([。；！？]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)

;; -------- Tab and Space --------
;; Permanently indent with spaces, never with TABs
(setq-default c-basic-offset     4
              default-tab-width  4
              tab-width          4
              indent-tabs-mode nil)

;; -------- line-wrapping column --------
(setq-default fill-column 80)

;; -------- case sensitive replace --------
(defadvice replace-string
    (around turn-off-case-fold-search)
  "Replace string with case sensitive."
  (let ((case-fold-search nil))
    ad-do-it))
(ad-activate 'replace-string)

;; -------- kill line including '\n' --------
;; (setq kill-whole-line t)

;; -------- whether add newline at bottom --------
;; (setq-default require-final-newline nil)

;; -------- always use `y-or-n-p' --------
(defalias 'yes-or-no-p 'y-or-n-p)
;; (fset 'yes-or-no-p 'y-or-n-p)

;; -------- disable left mouse button click paste --------
(setq mouse-yank-at-point t)
;; disable middle mouse button click
(global-unset-key (kbd "<mouse-2>"))
;; disable the right mouse button and double click to cut
(fset 'mouse-save-then-kill 'ignore)

(provide '+base)

;;; +base.el ends here
